﻿using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Wholesaler.Models.DBModels;
using Yunzuan.Common.Log;
using Yunzuan.Foundation.DataAccess;
using YunZuan.Models.Entities;
using Yunzuan.Foundation.Serializer;
using Yunzuan.Foundation.Web;
using Yunzuan.Foundation.Web_api;
using YunZuan.Models;

namespace Yunzuan.Common
{
    public class CommonCart
    {
        public static Type type = typeof(CommonCart);
        /// <summary>
        /// 添加商品到购物车
        /// </summary>
        /// <param name="goodType">商品类别ID</param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static string AddCartInfo(int goodType, string param)
        {
            HashParam HsParam = Json.Deserialize<HashParam>(param);
            string typeName = string.Empty;
            if (goodType == -1) //小程序直接在param裡面
            {
                if (HsParam.ContainsKey("GoodsTypeID"))
                    typeName = GoodsType.GetTypeName(HsParam.GetInt("GoodsTypeID").Value);
                else if (HsParam.ContainsKey("GoodsType"))
                    typeName = GoodsType.GetTypeName(HsParam.GetInt("GoodsType").Value); //兼容以前小程序与微信
                else
                    return string.Format(CommonConst.msgInfo, "false", "產品ID不能為空");
            }
            else
                typeName = GoodsType.GetTypeName(goodType);
            string key = CommonUrl.getURL(HsParam, param, typeName + "加入购物车");
            
            CommonConst.logParam = param;
            List<Cart> list = new List<Cart>();
            Cart cartinfos;
            
            CustomerInfo customer = YZ.GetDatabase(key).Get<CustomerInfo>(HsParam.GetInt("CustomerID"));//CustomerID必传
            if (customer != null)
            {
                string[] InventoryIDs ={};
                if( HsParam.ContainsKey("IDs")) 
                    InventoryIDs = HsParam.GetString("IDs").TrimEnd(',').Split(',');
                else if (HsParam.ContainsKey("InventoryIDs"))
                    InventoryIDs = HsParam.GetString("InventoryIDs").TrimEnd(',').Split(',');
                int addCount = 0;
                for (int i = 0; i < InventoryIDs.Length; i++)
                {
                    Hashtable hash = new Hashtable();
                    hash.Add("CustomerID",customer.CustomerID);
                    hash.Add("GoodsTypeID", goodType);
                    hash.Add("GoodsID", InventoryIDs[i]);
                    cartinfos = YZ.GetDatabase(key).QueryForObject<Cart>("Cart.GetCart", hash); 
                    if (cartinfos == null)
                    {
                        cartinfos = new Cart();
                        cartinfos.CustomerID = customer.CustomerID;//客户ID
                        cartinfos.UserID = customer.SalesUserID.Value; //业务ID
                        cartinfos.GoodsID = Convert.ToInt32(InventoryIDs[i]);
                        cartinfos.GoodsTypeID = goodType;
                        cartinfos.CreateTime = DateTime.Now;//加入购物车时间
                        cartinfos.CartType = HsParam.GetInt("CartType",0);
                        cartinfos.InventoryCount = (HsParam.ContainsKey("InventoryCount") ? HsParam.GetDecimal("InventoryCount") : 1);
                        list.Add(cartinfos); 
                    }
                    else if (cartinfos.GoodsTypeID == GoodsType.Parcel)
                    {
                        cartinfos.InventoryCount += (HsParam.ContainsKey("InventoryCount") ? HsParam.GetDecimal("InventoryCount") : 1);
                        YZ.GetDatabase(key).Edit(cartinfos);
                        return string.Format(CommonConst._msgInfo, "true", "加入购物车成功", 1, 0);
                    }
                    else
                    {
                        addCount++;
                    }
                }
                using (ITransaction tran_addRingCart = YZ.GetTransaction(key))
                {
                    try
                    {
                        if (list.Count == 0)
                            return string.Format(CommonConst._msgInfo, "true", "重复添加", list.Count, addCount);
                        else
                        {
                            tran_addRingCart.Insert("Cart.AddCartInfoList", list);
                            tran_addRingCart.CommitTransaction(); //提交  
                            return string.Format(CommonConst._msgInfo, "true", "加入购物车成功", list.Count, addCount);
                        }
                    }
                    catch (Exception ex)
                    {
                        CommonLog.GetMethodInfoAndWriteLogs(type,ex);
                        tran_addRingCart.RollBackTransaction();
                        return string.Format(CommonConst._msgInfo, "false", "加入购物车失败",0,0);
                    }
                }

            }


            return "";
        }
        /// <summary>
        /// 删除选中的商品
        /// </summary>
        /// <param name="goodType">商品类别ID</param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static string DelCartInfo(int goodType, string param)
        {
            CommonConst.logParam = param;

            HashParam str = JsonConvert.DeserializeObject<HashParam>(param);
            string key = CommonUrl.getURL(str,param, "删除购物车");

            Hashtable hash = new Hashtable();
            foreach (var item in str)
            {
                if (item.Key == "CustomerID")
                {
                    hash.Add("CustomerID", item.Value); 
                    hash.Add("GoodsTypeID", goodType);
                }
                if (item.Key == "CustomerIDs")
                {
                    string[] str2 = item.Value.ToString().Split(',');
                    hash.Add("CustomerIDs", str2);
                    hash.Add("GoodsTypeID", goodType);
                }
                if (item.Key == "CartIDs")
                {
                    string[] str2 = item.Value.ToString().Split(',');
                    hash.Add("CartIDs", str2); 
                }
                if (item.Key == "InventoryIDs")
                {
                    string[] str2 = item.Value.ToString().Split(',');
                    hash.Add("InventoryIDs", str2);
                }
            } 
            try
            {
               
                
                bool b= YZ.GetDatabase(key).Delete("Cart.DelCartInfoByIds", hash)>0;
                if (b)
                {
                    return string.Format(CommonConst._msgInfo, "true", "移除成功", 0, 0);
                }
                else
                    return string.Format(CommonConst._msgInfo, "false", "移除失败", 0, 0);
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(type,ex);
                return string.Format(CommonConst._msgInfo, "false", "程序错误",0,0);
            }
        }
        public static string DelCartInfo(int goodType, string key, int? CustomerID,int[] Ids)
        {
            try
            {  
                Hashtable hash = new Hashtable();
                hash.Add("CustomerID", CustomerID);
                hash.Add("GoodsTypeID", goodType);
                hash.Add("GoodsIDs", Ids);
                bool b = YZ.GetDatabase(key).Delete("Cart.DelCartInfoByIds", hash) > 0;
                if (b)
                {
                    return string.Format(CommonConst._msgInfo, "true", "移除成功", 0, 0);
                }
                else
                {
                    return string.Format(CommonConst._msgInfo, "false", "移除失败", 0, 0);
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(type, ex);
                return string.Format(CommonConst._msgInfo, "false", "程序错误", 0, 0);
            }
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="goodType"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static string UpdateCartInfo(int goodType, string param)
        {
            return "";
        }
        /// <summary>
        /// 查看购物车中的商品
        /// </summary>
        /// <param name="goodType">商品类别ID</param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static string SearchCartInfo(int goodType, string param, IList<Cart> cartInfoList = null)
        {
            CommonConst.logParam = param;
                HashParam hash = JsonConvert.DeserializeObject<HashParam>(param);
            string key =  CommonUrl.getURL(hash, param);
            try
            {
                //本地购物车id

                hash.Add("GoodsTypeID", goodType);
                bool isXcx = false; //小程序的请求 会传递cartInfoList
                if (cartInfoList == null)
                {
                    cartInfoList = YZ.GetDatabase(key).QueryForList<Cart>("Cart.GetCart", hash);//本地购物车是否存在加入
                }
                else {
                    isXcx = true;
                }
                if (cartInfoList != null && cartInfoList.Count>0)
                {
                      
                    //获取购物车的商品ID
                    var goodsID = from cart in cartInfoList
                                    select (int?)cart.GoodsID;
                    
                    string responseJson = CommonClass.AllProduct(CommonClass.GetGemIdsParamByCartInfoList(cartInfoList), GoodsType.GetGoodsUrlByTypId(GlobalConfig.filters, goodType), key, "post", true);//得到仓库的数据
                    #region 裸钻
                    if (GoodsType.Diamond == goodType)
                    {
                        string _msgInfo = "{\"msgcode\":#code,\"msginfo\":#msg,\"succ\":#succ,\"fail\":#fail,\"totalrmbct\":#rmbct,\"totalrmb\":#rmb,\"totalusdct\":#usdct,\"totalusd\":#usd}";
                        int Successful = 0;//在库
                        int Failed = 0;//被抢购 
                        decimal? TotalCustomerRMBPerCarat = 0;//总每卡人民币
                        decimal? TotalCustomerRMBPerGrain = 0;//总人民币
                        decimal? TotalCustomerUSDPerCarat = 0;//总每卡人民币
                        decimal? TotalCustomerUSDPerGrain = 0;//总人民币
                        responseJson = MyHttpRequest.ConvertToInventoryFormat(responseJson);
                        PageList<InventoryInfoResult> _doubleSellInventoryInfos = JsonConvert.DeserializeObject<PageList<InventoryInfoResult>>(responseJson);
                        if (_doubleSellInventoryInfos != null && _doubleSellInventoryInfos.Data.Count > 0)
                        {
                             
                            //获取商品的ID
                            var inventoryIDList = from d in _doubleSellInventoryInfos.Data
                                                    select d.ID;
                             
                            CustomerInfo customerInfo = YZ.GetDatabase(key).Get<CustomerInfo>(int.Parse(hash["CustomerID"].ToString()));//customerInfo为null
                            if (customerInfo == null)
                            {
                                return _msgInfo.Replace("#code", "false").Replace("#msg", JsonConvert.SerializeObject("客户标识不存在")).Replace("#succ", JsonConvert.SerializeObject(Successful)).Replace("#fail", JsonConvert.SerializeObject(Failed)).Replace("#rmbct", JsonConvert.SerializeObject(0)).Replace("#rmb", JsonConvert.SerializeObject(0));
                            }
                            Successful = _doubleSellInventoryInfos.Data.Count;//在库条目
                            Failed = cartInfoList.Count - Successful;//被抢购条目
                            SysSettingInfo setting = GoodsType.GetSystemSetting(key, GoodsType.Diamond);
                            //SystemSetting.tttagKey = key;
                            //SystemSetting setting = new SystemSetting();
                            //计算价格
                            DiamondsPriceHandlers diamondspricehandlers = new DiamondsPriceHandlers();
                            //转成字典方便获取对应Id的原始创建时间
                            var cartInfoListDict = cartInfoList.ToDictionary(t => t.GoodsID, t => t.CreateTime);
                            List<int> listId = new List<int>();
                            foreach (var item in _doubleSellInventoryInfos.Data)
                            {
                                listId.Add((int)item.ID.Value);
                                diamondspricehandlers.ComputePrice(item, customerInfo, setting, key);
                                //统计 总人民币每卡 总人民币
                                TotalCustomerRMBPerCarat += item.CustomerRMBPerCarat;
                                TotalCustomerRMBPerGrain += item.CustomerRMBPerGrain;
                                TotalCustomerUSDPerCarat += item.CustomerDolarPerCarat;
                                TotalCustomerUSDPerGrain += item.CustomerDolarPerGrain;
                                item.CreateTime = cartInfoListDict[item.ID.Value];//Cart原始创建下单时间排序
                            }
                            //按原始创建下单时间排序
                            var data = (IList<InventoryInfoResult>)_doubleSellInventoryInfos.Data.OrderByDescending(d => d.CreateTime).ToList();
                            _doubleSellInventoryInfos.Data = data;
                            { 
                                //得到已经被抢购的ID
                                var list = goodsID.Except(inventoryIDList);
                                if (list.Count() > 0)
                                {
                                    int[] listIDs = JsonConvert.DeserializeObject<int[]>(JsonConvert.SerializeObject(list));
                                    HashParam newHash = new HashParam();
                                    newHash.Add("CustomerID", hash["CustomerID"].ToString());
                                    newHash.Add("GoodsTypeID", hash["GoodsTypeID"].ToString());
                                    newHash.Add("GoodsIDs", listIDs);
                                    //删除被抢购的商品
                                    YZ.GetDatabase(key).Delete("Cart.DelCartInfoByIds", newHash);
                                }
                            }
                        }
                        else
                        {
                            //全部被抢购
                            //一旦全被抢购，清空本地购物车 11-16
                            #region
                            //清空购物车
                            YZ.GetDatabase(key).Delete("Cart.DelCartInfoByIds", hash);
                            #endregion
                            return _msgInfo.Replace("#code", "false").Replace("#msg", JsonConvert.SerializeObject("购物车被抢购一空")).Replace("#succ", JsonConvert.SerializeObject(0)).Replace("#fail", JsonConvert.SerializeObject(cartInfoList.Count)).Replace("#rmbct", JsonConvert.SerializeObject(cartInfoList.Count)).Replace("#rmb", JsonConvert.SerializeObject(0)).Replace("#usdct", JsonConvert.SerializeObject(cartInfoList.Count)).Replace("#usd", JsonConvert.SerializeObject(0));
                        }
                        if (isXcx)
                        {
                            return JsonConvert.SerializeObject(_doubleSellInventoryInfos).Replace("Data", "Rows");
                        }
                        else
                            return _msgInfo.Replace("#code", "true").Replace("#msg", JsonConvert.SerializeObject(_doubleSellInventoryInfos)).Replace("#succ", JsonConvert.SerializeObject(Successful)).Replace("#fail", JsonConvert.SerializeObject(Failed)).Replace("#rmbct", JsonConvert.SerializeObject(TotalCustomerRMBPerCarat)).Replace("#rmb", JsonConvert.SerializeObject(TotalCustomerRMBPerGrain)).Replace("#usdct", JsonConvert.SerializeObject(TotalCustomerUSDPerCarat)).Replace("#usd", JsonConvert.SerializeObject(TotalCustomerUSDPerGrain));

                    }
                    #endregion
                    else
                    {
                        // RingInfoResult  list=JsonConvert.DeserializeObject<RingInfoResult>(responseJson);
                        //responseJson = MyHttpRequest.ConvertToInventoryFormat(responseJson);
                        HashParam hsParam = JsonConvert.DeserializeObject<HashParam>(responseJson);
                        if (hsParam.Count > 0)
                        {
                            string ss = hsParam["rows"].ToString();
                            List<Dictionary<object, object>> listStr = JsonConvert.DeserializeObject<List<Dictionary<object, object>>>(ss);
                            CommonClass cc = new CommonClass();
                            for (int i = 0; i < listStr.Count; i++)
                            {
                                string supplierCode = listStr[i]["Supplier"].ToString();

                                if (GoodsType.InlaySettings == goodType)
                                //listStr[i]["GoldPrice"] = Convert.ToDecimal(listStr[i]["GoldPrice"].ToString()) * iscount;
                                {
                                    CustomerInfo customer = YZ.GetDatabase(key).Get<CustomerInfo>(int.Parse(hash["CustomerID"].ToString()));
                                    decimal supplierRate = 1;
                                    decimal settingRate = 1;
                                    //原卖价
                                    decimal CustomerRMB = (Convert.ToDecimal(listStr[i]["GoldPrice"].ToString()) * Convert.ToDecimal(listStr[i]["NetGoldWeight"].ToString()) * (1 + Convert.ToDecimal(listStr[i]["Wastage"].ToString())))
                                            + Convert.ToDecimal(listStr[i]["SideLaborFee"].ToString()) * Convert.ToDecimal(listStr[i]["SideNum"].ToString()) + Convert.ToDecimal(listStr[i]["SidePrice"].ToString())
                                            + Convert.ToDecimal(listStr[i]["LaborFee"].ToString())
                                            + Convert.ToDecimal(listStr[i]["Insurance"].ToString());
                                    if (customer.IsSetInlaySettings == 0)
                                    {
                                        decimal ConfirmRMB = CustomerRMB * (1 + (supplierRate - 1) + (settingRate - 1) + (Convert.ToDecimal(customer.InlaySettingsRebate) - 1)) * customer.Discounts.Value;
                                        listStr[i].Add("Price", ConfirmRMB);

                                        if ((1 + (supplierRate - 1) + (settingRate - 1) + (Convert.ToDecimal(customer.InlaySettingsRebate) - 1)) != 1)
                                        {
                                            decimal CustomerRMB1 = CustomerRMB * (1 + (supplierRate - 1) + (settingRate - 1) + (Convert.ToDecimal(customer.InlaySettingsRebate) - 1));
                                            decimal resultDisc = (1 + (supplierRate - 1) + (settingRate - 1) + ((CustomerRMB1 / CustomerRMB) - 1));

                                            //反推出最后的结果
                                            listStr[i].Add("CustomerGoldPrice", Math.Round(Convert.ToDecimal(listStr[i]["GoldPrice"].ToString()) * resultDisc));//金价
                                            listStr[i].Add("CustomerWastage", Convert.ToDecimal(listStr[i]["Wastage"].ToString()));//损耗
                                            listStr[i].Add("CustomerSideLaborFee", Math.Round(Convert.ToDecimal(listStr[i]["SideLaborFee"].ToString()) * resultDisc));//副石工费
                                            listStr[i].Add("CustomerLaborFee", Math.Round(Convert.ToDecimal(listStr[i]["LaborFee"].ToString()) * resultDisc));//工费
                                            listStr[i].Add("CustomerSidePrice", Math.Round(Convert.ToDecimal(listStr[i]["SidePrice"].ToString()) * resultDisc));//副石总额
                                            listStr[i].Add("CustomerInsurance", Math.Round(Convert.ToDecimal(listStr[i]["Insurance"].ToString()) * resultDisc));//保险费 

                                        }
                                        else
                                        {
                                            listStr[i].Add("CustomerGoldPrice", Convert.ToDecimal(listStr[i]["GoldPrice"].ToString()));//金价
                                            listStr[i].Add("CustomerWastage", Convert.ToDecimal(listStr[i]["Wastage"].ToString()));//损耗
                                            listStr[i].Add("CustomerSideLaborFee", Convert.ToDecimal(listStr[i]["SideLaborFee"].ToString()));//副石工费
                                            listStr[i].Add("CustomerLaborFee", Convert.ToDecimal(listStr[i]["LaborFee"].ToString()));//工费
                                            listStr[i].Add("CustomerSidePrice", Convert.ToDecimal(listStr[i]["SidePrice"].ToString()));//副石总额
                                            listStr[i].Add("CustomerInsurance", Convert.ToDecimal(listStr[i]["Insurance"].ToString()));//保险费 
                                        }
                                    }
                                    else if (customer.IsSetInlaySettings == 1)
                                    {
                                        CustomerSetInlaySetttings setInlaySetttings = Yunzuan.Foundation.Serializer.Json.Deserialize<CustomerSetInlaySetttings>(customer.InlaySettingsRebate);
                                        //在原价的基础上 对客户设置空托的加价系数 得到的结果
                                        decimal CustomerRMB1 = ((Convert.ToDecimal(listStr[i]["GoldPrice"].ToString()) + setInlaySetttings.GoldPrice) * Convert.ToDecimal(listStr[i]["NetGoldWeight"].ToString()) * (1 + Convert.ToDecimal(listStr[i]["Wastage"].ToString()) + setInlaySetttings.Wastage / 100)) //金价*净金重*（1+损耗）
                                                            + (Convert.ToDecimal(listStr[i]["SideLaborFee"].ToString()) + setInlaySetttings.SideLaborFee) * Convert.ToDecimal(listStr[i]["SideNum"].ToString())//   副石工费 * 副石粒数
                                                            + (Convert.ToDecimal(listStr[i]["LaborFee"].ToString()) * setInlaySetttings.LaborFee) //工费
                                                            + (Convert.ToDecimal(listStr[i]["SidePrice"].ToString()) * setInlaySetttings.SidePrice) //副石总额
                                                            + (Convert.ToDecimal(listStr[i]["Insurance"].ToString()) * setInlaySetttings.Insurance);//保险费
                                        decimal resultDisc = (1 + (supplierRate - 1) + (settingRate - 1) + ((CustomerRMB1 / CustomerRMB) - 1));
                                        if (resultDisc == CustomerRMB1 / CustomerRMB)
                                        {
                                            //这是客户购买空托的时候 金价 损耗  副石工费  工费  副石总额  保险费

                                            listStr[i].Add("CustomerGoldPrice", Convert.ToDecimal(listStr[i]["GoldPrice"].ToString()) + setInlaySetttings.GoldPrice);//金价
                                            listStr[i].Add("CustomerWastage", Convert.ToDecimal(listStr[i]["Wastage"].ToString()) + setInlaySetttings.Wastage / 100);//损耗
                                            listStr[i].Add("CustomerSideLaborFee", Convert.ToDecimal(listStr[i]["SideLaborFee"].ToString()) + setInlaySetttings.SideLaborFee);//副石工费
                                            listStr[i].Add("CustomerLaborFee", Convert.ToDecimal(listStr[i]["LaborFee"].ToString()) * setInlaySetttings.LaborFee);//工费
                                            listStr[i].Add("CustomerSidePrice", Convert.ToDecimal(listStr[i]["SidePrice"].ToString()) * setInlaySetttings.SidePrice);//副石总额
                                            listStr[i].Add("CustomerInsurance", Convert.ToDecimal(listStr[i]["Insurance"].ToString()) * setInlaySetttings.Insurance);//保险费 

                                        }
                                        else
                                        {
                                            //反推出最后的结果
                                            listStr[i].Add("CustomerGoldPrice", Math.Round(Convert.ToDecimal(listStr[i]["GoldPrice"].ToString()) * resultDisc));//金价
                                            listStr[i].Add("CustomerWastage", Math.Round(Convert.ToDecimal(listStr[i]["Wastage"].ToString()) * resultDisc, 2));//损耗
                                            listStr[i].Add("CustomerSideLaborFee", Math.Round(Convert.ToDecimal(listStr[i]["SideLaborFee"].ToString())));//副石工费
                                            listStr[i].Add("CustomerLaborFee", Math.Round(Convert.ToDecimal(listStr[i]["LaborFee"].ToString()) * resultDisc));//工费
                                            listStr[i].Add("CustomerSidePrice", Math.Round(Convert.ToDecimal(listStr[i]["SidePrice"].ToString()) * resultDisc));//副石总额
                                            listStr[i].Add("CustomerInsurance", Math.Round(Convert.ToDecimal(listStr[i]["Insurance"].ToString()) * resultDisc));//保险费 
                                        }
                                        decimal ConfirmRMB = Math.Round(CustomerRMB * resultDisc * customer.Discounts.Value);
                                        listStr[i].Add("Price", ConfirmRMB);

                                    }
                                }
                                else if (GoodsType.PrimeGolds == goodType)
                                { 
                                    decimal iscount = cc.GetDiscount(key, goodType, int.Parse(hash["CustomerID"].ToString()), supplierCode);
                                    decimal price= Convert.ToDecimal(listStr[i]["TotalWeight"].ToString()) * (Convert.ToDecimal(listStr[i]["GoldPrice"].ToString()) + Convert.ToDecimal(listStr[i]["LaborFee"].ToString()));
                                    listStr[i].Add("Price", price * iscount);
                                }
                                else
                                {
                                    decimal iscount = cc.GetDiscount(key, goodType, int.Parse(hash["CustomerID"].ToString()), supplierCode);
                                    listStr[i]["Price"] = Convert.ToDecimal(listStr[i]["Price"].ToString()) * iscount;
                                }

                                int id = Convert.ToInt32(listStr[i]["ID"]);
                                var count = from m in cartInfoList
                                            where m.GoodsID.Equals(id)
                                            select new { m.CartID, m.InventoryCount };
                                listStr[i].Add("InventoryCount", count.ToArray()[0].InventoryCount);
                                listStr[i].Add("CartID", count.ToArray()[0].CartID);
                            }
                            hsParam["rows"] = listStr;
                            responseJson = JsonConvert.SerializeObject(hsParam);
                            if (isXcx)
                                return responseJson;
                        }
                        //decimal iscount = CommonClass.GetDiscount(goodType, int.Parse(hash["CustomerID"].ToString()), "0");

                    }
                    return string.Format(CommonConst.msgObj, "true", responseJson);
                } 
                else
                {
                    return string.Format(CommonConst._msgInfo, "false", "购物车为空",0,0);
                }
            }
            catch (Exception ex)
            {
                CommonLog.GetMethodInfoAndWriteLogs(type,ex);
                return string.Format(CommonConst._msgInfo, "false", "程序错误",0,0);
            }
        }
    }
}
